package com.oocl.util;

import java.util.ArrayList;
import java.util.List;

import com.oocl.pojo.Food;
import com.oocl.pojo.Merchant;
import com.oocl.vo.MerchandiseVO;
import com.oocl.vo.MerchantVO;

/**
 * @description: 
 * @author  XIEMI2
 * @date Jul 29, 2017 10:23:49 AM
 * @version 1.0
 */
public class ObjConvertUtil {
	
	private static final String IMG_PATH_PREFIX = MerchantSysConfigUtil.getProperties().getProperty("IMG_PATH_PREFIX");
	
	/**
	 * @description 将单个 merchantDTO 转换为 MerchantVO
	 * @param dto
	 * @param vo
	 */
	public static void merchantDOToVO(Merchant mDO, MerchantVO vo){
		vo.setId(mDO.getId());
		vo.setUname(mDO.getUname());
		vo.setHeadImg(IMG_PATH_PREFIX+mDO.getHeadImg());
		vo.setAddress(mDO.getAddress());
	}
	
	/**
	 * @description 将多个 merchantDTO 转换为 MerchantVO
	 * @param dtos
	 * @return List<Merchant>
	 */
	public static List<MerchantVO> merchantDOsToVOs(List<Merchant> dos){
		List<MerchantVO> vos = new ArrayList<MerchantVO>();
		for(Merchant mDO:dos){
			MerchantVO vo = new MerchantVO();
			merchantDOToVO(mDO, vo);
			vos.add(vo);
		}
		return vos;
	}

	public static List<MerchandiseVO> foodDOsToMerchaniseVOs(List<Food> foodDOs){
		List<MerchandiseVO> merchandiseVOs = new ArrayList<MerchandiseVO>();
		for(Food f:foodDOs){
			MerchandiseVO m = new MerchandiseVO(f.getId(), f.getName(), f.getPrice(), IMG_PATH_PREFIX+f.getImg());
			merchandiseVOs.add(m);
		}
		return merchandiseVOs;
	}
	
}


